package com.benmei.ntlive.dto.ntmsg.cons;

/**
 * Created by Peter on 2017/11/21.
 *
 * 客户端操作系统类型：1 Android; 2 IOS;
 */
public enum ClientOSType {
    Android(1, "Android"),

    IOS(2, "IOS");

    private final int value;

    private final String name;


    ClientOSType(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    public static boolean validate(String name) {
        boolean result = false;
        for (ClientOSType role : ClientOSType.values()) {
            if (role.getName().equals(name)) {
                result = true;
                break;
            }
        }
        return result;
    }

    public static ClientOSType getByValue(int value) {
        for (ClientOSType o : ClientOSType.values()) {
            if (o.getValue() == value) {
                return o;
            }
        }
        return null;
    }

    public static ClientOSType getByName(String name) {
        for (ClientOSType o : ClientOSType.values()) {
            if (o.name == name) {
                return o;
            }
        }
        return null;
    }
}
